local jinqi = fk.CreateSkill {
    name = "steam__jinqi",
    tags = {Skill.Limit},
}



Fk:loadTranslationTable{
    ["steam__jinqi"] = "烬起",
    [":steam__jinqi"] = "限定技，准备阶段，你可将一名其他角色的已损失体力值当等量张不同的即时牌使用，然后变更势力。",

    ["#steam__jinqi-invoke"] = "烬起：你可以将一名其他角色的已损失体力值当等量张不同的即时牌使用，然后变更势力。",
    ["#steam__jinqi-change"] = "烬起：请选择要变更的势力",
}
--这个技能据设计者的本意是令一名角色失去所有已损失的体力上限，你视为使用等量张不同的基本牌和普通锦囊
jinqi:addEffect(fk.EventPhaseStart, {
    anim_type = "control",--特效
    can_trigger = function(self, event, target, player, data)
      return target == player and player:hasSkill(jinqi.name) and player.phase == Player.Start and 
      table.find(player.room:getOtherPlayers(player), function(p)
        return p:isWounded()
      end) and player:usedSkillTimes(jinqi.name,Player.HistoryGame) < 1
    end,
    on_cost = function(self, event, target, player, data)
        local room = player.room
        local targets = table.filter(room.alive_players, function(p)
          return p ~= player and p:isWounded()
        end)
        local tos = room:askToChoosePlayers(player, {
          targets = targets,
          min_num = 1,
          max_num = 1,
          prompt = "#steam__jinqi-invoke",
          skill_name = "steam__jinqi",
        })
        if #tos > 0 then
          event:setCostData(self, {tos = tos})
          return true
        end
    end,
    on_use = function(self, event, target, player, data)
        local room = player.room
        local tar=event:getCostData(self).tos[1]
        local num=tar:getLostHp()
        room:changeMaxHp(tar, -num)--失去空的体力上限
        --获得可用的即时牌
        local all_names = Fk:getAllCardNames("bt")
        local used_names={}
        for i=1,num do--使用等量张不同即时牌
            local names = player:getViewAsCardNames(jinqi.name, all_names, nil,used_names)--可用即时牌
            local use=room:askToUseVirtualCard(player, {
                name = names, skill_name = jinqi.name, cancelable = true,
              })
            if use then
                table.insert(used_names,use.card.name)
            end
        end
        --变更势力
        local kingdoms = Fk:getKingdomMap("god")
        local choices = table.simpleClone(kingdoms)
        table.removeOne(choices, player.kingdom)
        table.insertIfNeed(choices, "jin")
        local choice = room:askToChoice(player, {
          choices = choices,
          skill_name = jinqi.name,
          prompt = "#steam__jinqi-change",
        })
        if choice ~= "Cancel" then
          room:changeKingdom(player, choice, true)
        end
    end,
})

return jinqi